package com.example.myapplication;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;

public class BootReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
            // 设备重启后重新设置定时
            new Handler(Looper.getMainLooper()).postDelayed(() -> {
                MainActivity activity = new MainActivity();
                activity.initTimerTask();
            }, 5000); // 延迟5秒确保系统就绪
        }
    }
}
